﻿package mortal.game.view.mainUI.roleAvatar
{
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class FightModeCellRenderer extends GCellRenderer
    {
        private var _icon:GBitmap;
        private var _fightModeDec:GTextFiled;
        private var _fightMode:int;

        public function FightModeCellRenderer()
        {
            return;
        }// end function

        override protected function initSkin() : void
        {
            var _loc_1:* = new GBitmap();
            var _loc_2:* = UIFactory.bg(0, 0, 280, 138, null, ImagesConst.Menu_overSkin);
            this.setStyle("downSkin", _loc_1);
            this.setStyle("overSkin", _loc_2);
            this.setStyle("upSkin", _loc_1);
            this.setStyle("selectedDownSkin", _loc_2);
            this.setStyle("selectedOverSkin", _loc_2);
            this.setStyle("selectedUpSkin", _loc_2);
            return;
        }// end function

        override protected function configUI() : void
        {
            super.configUI();
            this._icon = UIFactory.gBitmap("", 5, 2, this);
            this._fightModeDec = UIFactory.gTextField("", 30, 4, 290, 20, this);
            this.addEventListener(MouseEvent.CLICK, this.setMode);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            this._fightMode = param1.data as int == 1 ? (EntityRelationUtil.getMapFightMode()) : (param1.data);
            this._icon.bitmapData = GlobalClass.getBitmapData("FightMode" + this._fightMode + "_upSkin");
            var _loc_2:* = GameDefConfig.instance.getFightModeName(this._fightMode);
            var _loc_3:* = GameDefConfig.instance.getFightModeDec(this._fightMode);
            if (this._fightMode == 0)
            {
                this._fightModeDec.htmlText = Language.getStringByParam(30150, _loc_2, _loc_3);
            }
            else
            {
                this._fightModeDec.htmlText = Language.getStringByParam(30152, _loc_2, _loc_3);
            }
            return;
        }// end function

        private function setMode(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.FightSetMode, this._fightMode == 0 ? (0) : (2)));
            return;
        }// end function

    }
}
